<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>

<head>
</head>
<style>
.leg_operation {
	margin-left: -10%;
}

.mui-btn, button, input[type=button], input[type=reset], input[type=submit]
	{
	padding: 6px 10px;
}
</style>

<body>
	<div id="leg_table"></div>
	<script type="text/html" id="caseTypeBar">
			<a class="mui-btn mui-btn-primary edit">编辑</a>
			<a class="mui-btn mui-btn-primary del">删除</a>
			<a class="mui-btn mui-btn-primary isDefault">设为默认</a>
		</script>
	<script type="text/javascript">
			mui('#offCanvasContentScroll').scroll().scrollTo(0,0);
	
			$(".mui-title").html("计费类型");
			
			//接收数据
			var stateList = $.legTable({
				limit: 10,			//默认10
				page:1,				//默认1
				id:"#leg_table",	//绑定id
				url:"/caseType/getCaseTyepList",
				cols:[
					{field: 'name', title: '名称'},
		            {field: 'payType', title: '计费方式'},
		            {field: 'payTime', title: '收费时间'},
		            {field: 'price', title: '常规柜子价格'},
		            {field: 'priceSize', title: '大中小柜价格'},
		            {field: 'compName', title: '公司'},
		            {field: 'isDefault', title: '是否默认',templet:function(f){
		            	if(f.isDefault == 1){
		            		return "<span style='color:red;'>是</span>"
		            	}else{
		            		return "<span>否</span>"
		            	}
		            } },
		            {title: '操作', templet:'#caseTypeBar'}
		        ]
			});

			//添加
			$("#Add").show();
			$("#Add").on("touchstart",function(e){
				$("#Add").hide();
				url = "/caseType/add";
				sessionStorage.setItem("url",url)
				window.location.hash = url;
			})
			
			//编辑
			$("#leg_table").on("touchstart", ".table-list .edit", function(e){
				let i = $(this).parent('data').attr("value");
				let url = '/caseType/caseEdit?typeId='+$.data(i).typeId;
				sessionStorage.setItem("url",url)
				window.location.hash = url;
		    })
           	
           //删除
           $("#leg_table").on("touchstart", ".table-list .del", function(e){
        	    let i = $(this).parent('data').attr("value");
       	    	mui.confirm('确定删除此计费信息？','温馨提示',function(e) {
					if (e.index == 1) {
						$.get("/caseType/deleteCaseTyep?typeId="+$.data(i).typeId,function(res){
			           		if (!res.success) {
			           			mui.toast(res.message);
			       			}else{
			       				mui.toast("删除成功");
			       				stateList = $.legTable();
			       			}
			           	})
					}
				})
            })
            
            //设置默认
           $("#leg_table").on("touchstart", ".table-list .isDefault", function(e){
        	    let i = $(this).parent('data').attr("value");
            	mui.confirm('设为默认后，以后的储物柜都会按照此收费标准收费，如需改动可手动修改？','温馨提示',function(e) {
					if (e.index == 1) {
						$.get("/caseType/setDefault?typeId="+$.data(i).typeId,function(res){
			           		if (!res.success) {
			           			mui.toast(res.message);
			       			}else{
			       				mui.toast("设置成功");
			       				stateList = $.legTable();
			       			}
			           	})
					}
				})
       	     })
			
		</script>
</body>

</html>